#include "comm.h"
#include <unistd.h>

int main()
{
  key_t key = ftok(PATH_NAME, PRO_ID);
  if(key < 0) {
    perror("ftok");
    return 1;
  }
  int shmid = shmget(key, SIZE, IPC_CREAT);
  if(shmid < 0) {
    perror("shmid");
    return 2;
  }
  printf("0x%x\n", key);
  sleep(5);
  char* mem = (char*)shmat(shmid, NULL, 0);
  printf("client attaches successfully!\n");
  //sleep(5);
  
  // 通信
  char c = 'A';
  while(c < 'Z') {
    mem[c-'A'] = c;
    c++;
    mem[c-'A'] = 0;
    sleep(2);
  }



  shmdt(mem);
  printf("client detaches successfully!\n");
  sleep(5);


}
